package com.leorui.schoollife.entity

import net.sf.json.JSONObject
import java.io.Serializable


class PersonalInfoResponse : Serializable {
    var status: Int? = null
    var icon: PhotoEntity? = null // 头像
    var account: String? = null // 账号
    var power: String? = null // 权力
    var nickname: String? = null // 昵称
    var friendCircleCount: Int? = null // 朋友圈个数
    var sex: Int? = null // 性别
    var school: SchoolEntity? = null // 学校
    var phone: String? = null // 电话
    var area: String? = null // 地区
    var studentId: String? = null // 学生id
    var teacherId: String? = null // 教师id
    var administratorId: String? = null // 管理员id
    var teachClass: String? = null // 所教课程
    var personalProfile: String? = null // 个人简介
    fun toMap(): Map<Any?, Any?> {
        val json = JSONObject()
        json["status"] = status
        json["icon"] = icon?.toMap()
        json["account"] = account
        json["power"] = power
        json["nickname"] = nickname
        json["friend_circle_count"] = friendCircleCount
        json["sex"] = sex
        json["school"] = school?.toMap()
        json["phone"] = phone
        json["area"] = area
        json["student_id"] = studentId
        json["teacher_id"] = teacherId
        json["administrator_id"] = administratorId
        json["teach_class"] = teachClass
        json["personal_profile"] = personalProfile
        return json.toMap()
    }
}


class ManagerAccount : StudentAccount() {
    var managerId: String? = null
    override fun toJson(): JSONObject {
        val json = super.toJson()
        json["manager_id"] = managerId
        return json
    }

    override fun toMap(): Map<Any?, Any?> {
        val json = super.toJson()
        json["manager_id"] = managerId
        return json.toMap()
    }
}


class TeacherAccount : StudentAccount() {
    var teachCourse: String? = null
    var teacherId: String? = null
    override fun toJson(): JSONObject {
        val json = super.toJson()
        json["teacher_id"] = teacherId
        json["teach_course"] = teachCourse
        return json
    }

    override fun toMap(): Map<Any?, Any?> {
        val json = super.toJson()
        json["teacher_id"] = teacherId
        json["teach_course"] = teachCourse
        return json.toMap()
    }
}

open class StudentAccount : Serializable {
    var account: String? = null
    var password: String? = null
    var personalProfile: String? = null
    var nickname: String? = null
    var schoolName: String? = null
    var power: Int? = null
    var sex: Int? = null
    var icon: PhotoEntity? = null
    var area: String? = null

    open fun toJson(): JSONObject {
        val json = JSONObject()
        json["account"] = account
        json["password"] = password
        json["personal_profile"] = personalProfile
        json["nickname"] = nickname
        json["school_name"] = schoolName
        json["power"] = power
        json["sex"] = sex
        json["icon"] = icon?.toJson()
        json["area"] = area
        return json
    }

    open fun toMap(): Map<Any?, Any?> {
        val json = JSONObject()
        json["account"] = account
        json["password"] = password
        json["personal_profile"] = personalProfile
        json["nickname"] = nickname
        json["school_name"] = schoolName
        json["power"] = power
        json["sex"] = sex
        json["icon"] = icon?.toMap()
        json["area"] = area
        return json.toMap()
    }
}

